<?php

function fnMstPembeli() {
    $results = mysql_query("SELECT	
                                Nama,
                                Alamat,
                                Telp,
                                Email,
                                Milist,
                                Login,
                                Password
                            FROM
                                mst_pembeli");
    return $results;
}

function fnPembeliById($id) {
    $results = mysql_query("SELECT	
                                Nama,
                                Alamat,
                                Telp,
                                Email,
                                Milist,
                                Login,
                                Password
                            FROM
                                mst_pembeli
                            WHERE id = ".$id);
    return $results;
}

function fnAllPembeli() {
    $results = mysql_query("select c.* from (
                            select @rownum:=@rownum+1 as rownum, a.*
                            from mst_pembeli a, (select @rownum:=0) b
                            ) c ");
    return $results;
}

function fnAllPembeliByRange($startNum, $endNum) {
    $results = mysql_query("select c.* from (
                            select @rownum:=@rownum+1 as rownum, a.*
                            from mst_pembeli a, (select @rownum:=0) b
                            ) c where 1=1
                            and c.rownum between ".$startNum." and ".$endNum);
    return $results;
}

function fnInsertPembeli($Nama,$Alamat,$Telp,$Email,$Milist,$Login,$Password) {
  $result = mysql_query("INSERT INTO mst_pembeli 
                          	(Nama,Alamat,Telp,Email,Milist,Login,Password)
                         VALUES
                          	('$Nama','$Alamat','$Telp','$Email',$Milist,'$Login','$Password')
                         ");
  return $result;
}

function fnUpdatePembeli($Id,$Nama,$Alamat,$Telp,$Email,$Milist,$Login,$Password) {
  $result = mysql_query("UPDATE mst_pembeli SET 
                              	Nama = '$Nama',
                              	Alamat = '$Alamat',
                              	Telp = '$Telp',
                              	Email = '$Email',
                                Milist = $Milist,
                                Login = '$Login',
                                Password = '$Password'
                         WHERE Id = $Id");
  return $result;
}

function fnDeletePembeli($Id) {
  $result = mysql_query("DELETE FROM mst_pembeli 
                         WHERE Id = ".$Id);
  return $result;
}

?>
